<template>
	<view class="productItem">
		<view class="user-info">
			<!-- <uni-icons type="contact" class="icon" size="26" color="#222"></uni-icons> -->
			<view class="name">
				<text>{{ source.parkingSpace }}</text>
				<uni-icons type="arrow-right" class="icon" size="20" color="#666666"></uni-icons>
				<text>{{ source.cityName }}</text>
			</view>
			<view class="status">
				{{ statusList[source.status] }}
			</view>
		</view>
		<view class="info-wrapper">
			<view class="item">
				<text class="licensePlateNo">{{ source.licensePlateNo }}</text>
				<text class="vehicleModel">({{ source.vehicleModel }})</text>
			</view>
			<view class="item">
				<text>司机：{{ source.driverName }}</text>
				<text v-if="source.driverTel">({{ source.driverTel }})</text>
			</view>
			<view class="item">
				<text>装车：{{ source.loaderName }}</text>
				<text v-if="source.loaderTel">({{ source.loaderTel }})</text>
			</view>
		</view>
		<view class="btn-wrapper">
			<view v-if="source.status > 1" class="date">
				发车时间:{{ source.departureTime }}
			</view>
			<view class="btn" @click="goDetail(source)">
				运输单
			</view>
			<view class="btn" v-if="source.status === 1" @click="goEdit(source)">
				编辑
			</view>
			<view v-if="source.status === 1 && $permissions.verify('app:transpot:dispatch:depart')" class="btn primary"
				@click.stop="depart(source)">
				发车
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			index: {
				type: Number,
				default () {
					return 0
				}
			},
			source: {
				type: Object,
				default () {
					return {}
				}
			}
		},
		data() {
			return {
				statusList: ['车未到位', '装车中', '运输中', '已完成']
			}
		},
		mounted() {

		},
		methods: {
			depart(row) {
				uni.navigateTo({
					url: '/subPage_distribution/depart?id=' + row.id + '&params=' + JSON.stringify(row)
				})
			},
			goDetail(row) {
				uni.navigateTo({
					url: '/subPage_distribution/vehiclesPlanDetail?id=' + row.id + '&params=' + JSON.stringify(row)
				})
			},
			goEdit(row) {
				uni.navigateTo({
					url: '/subPage_distribution/vehiclesPlanEdit?id=' + row.id + '&params=' + JSON.stringify(row)
				})
			},
		},
		components: {

		}
	}
</script>

<style lang="scss" scoped>
	.productItem {
		background-color: #ffffff;
		border-radius: 10upx;
		padding: 20upx;

		.user-info {
			display: flex;
			align-items: center;
			font-size: 32upx;
			padding: 0 20upx;

			.name {
				font-weight: bold;
				flex: 1;
				color: #222222;
				font-size: 34upx;
			}

			.status {
				color: #f3810e;
			}

			.icon {
				margin-right: 5upx;
			}
		}

		.region {
			padding: 0 20upx;
			color: #888888;
			margin-top: 10upx;
		}

		.info-wrapper {
			margin: 20upx 20upx;
			border-top: 1upx dashed #e1e1e1;
			border-bottom: 1upx dashed #e1e1e1;
			padding: 20upx 0;

			.item {
				display: flex;
				align-items: center;
				font-size: 32upx;
				margin-bottom: 10upx;
				color: #434343;

				.licensePlateNo {
					font-weight: bold;
					font-size: 32upx;
				}

				.vehicleModel {
					font-size: 28upx;
					color: #666;
				}
			}
		}

		.delivery-quantity {
			display: flex;
			align-items: center;
			padding: 20upx 0;
			margin-top: 20upx;
			border-top: 1upx solid #efefef;

			.item {
				flex: 1;
				font-size: 30upx;

				&.center {
					text-align: center;
				}

				&.right {
					text-align: right;
				}
			}
		}

		.btn-wrapper {
			display: flex;
			align-items: center;
			justify-content: flex-end;
			margin-top: 10upx;

			.date {
				flex: 1;
				font-size: 32upx;
				color: #666;
			}

			.btn {
				padding: 16upx 40upx;
				background-color: #ffffff;
				border: 1upx solid #bababa;
				border-radius: 10upx;
				font-size: 28upx;
				margin-left: 15upx;

				&.primary {
					color: #ffffff;
					background-color: #555BFF;
					border-color: #555BFF;
				}
			}
		}
	}
</style>